<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商家店铺列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>后台账号：</label>
                            <input type="text" name="loginName"/>
                        </li>
                        <li>
                            <label>商铺分类：</label>
                            <select name="shopTypeId" th:with="list=${@dict.selectShopTypeList()}">
                                <option value="">所有</option>
                                <option th:each="shopType : ${list}" th:text="${shopType.typeName}"
                                        th:value="${shopType.id}"></option>
                            </select>
                        </li>
                        <li>
                            <label>单位名称：</label>
                            <input type="text" name="shopCompany"/>
                        </li>
                        <li>
                            <label>管理员手机号：</label>
                            <input type="text" name="shopTel"/>
                        </li>
                        <li>
                            <label>商铺区域：</label>
                            <input type="text" id="treeName" onclick="selectCityTree()"/>
                            <input type="text" name="shopCityId" id="shopCityId" hidden/>
                        </li>
                        <li>
                            <label>让利比：</label>
                            <select name="discountRatio">
                                <option value="">请选择</option>
                                <option value="0.02">2%</option>
                                <option value="0.03">3%</option>
                                <option value="0.04">4%</option>
                                <option value="0.05">5%</option>
                                <option value="0.06">6%</option>
                                <option value="0.07">7%</option>
                                <option value="0.08">8%</option>
                                <option value="0.09">9%</option>
                                <option value="0.10">10%</option>
                                <option value="0.11">11%</option>
                                <option value="0.12">12%</option>
                                <option value="0.13">13%</option>
                                <option value="0.14">14%</option>
                                <option value="0.15">15%</option>
                            </select>
                        </li>
                        <input type="text" name="isValid" value="1" hidden/>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--     <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="WxShop:WxShop:add">
                     <i class="fa fa-plus"></i> 添加
                 </a>
                 <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
                    shiro:hasPermission="WxShop:WxShop:edit">
                     <i class="fa fa-edit"></i> 修改
                 </a>
                 <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
                    shiro:hasPermission="WxShop:WxShop:remove">
                     <i class="fa fa-remove"></i> 删除
                 </a>
                 <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="WxShop:WxShop:export">
                     <i class="fa fa-download"></i> 导出
                 </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('WxShop:WxShop:edit')}]];
    var removeFlag = [[${@permission.hasPermi('WxShop:WxShop:remove')}]];
    var wxUserId = [[${wxUserId}]];

    var prefix = ctx + "WxShop/WxShop";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            modalName: "商家店铺",
            columns: [
                {
                    field: 'id',
                    title: 'null',
                    visible: false
                },
                {
                    field: 'shopName',
                    title: '商铺名称'
                },
                {
                    field: 'loginName',
                    title: '账号'
                },
                {
                    field: 'shopCompany',
                    title: '单位名称'
                },
                {
                    field: 'shopTel',
                    title: '管理员电话'
                },
                {
                    field: 'discountRatio',
                    title: '让利比'
                },
                {
                    field: 'shopMoney',
                    title: '商户余额'
                },
                {
                    field: 'typeName',
                    title: '商铺分类',

                },
                {
                    field: 'cityName',
                    title: '地区',
                },
                {
                    field: 'shopAdress',
                    title: '店铺地址'
                }
              ],
            onClickRow:function (row) {
                $.modal.confirm("确认改变此用户归属-->"+row.shopCompany+"<--吗?",function () {
                    $.operate.post(ctx+"WxUser/WxUser/changeBelongShop",{wxUserId:wxUserId,shopId:row.id},function (result) {
                        $.operate.successTabCallback(result);
                    })
                })
            }
        };
        $.table.init(options);
    });



    function selectCityTree() {
        var url = ctx + "WxCitys/WxCitys/selectCitysTree/" + 100;
        var options = {
            title: '选择城市',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#shopCityId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    }
</script>
</body>
</html>